I wrote this compact program getting a suggestion from one of my acquaintance.
I hopefully think it would be a help for those who are about to start programming on Macintosh.
Since I am not a skilled nor talented programmer, the source codes may be neither easy-to-understand nor well considered for educational aims.
Though, I will be happy if they can help novices as an example of a small-scale programming.
2. Structure of the Sources folder
Project Files:
Bye.TC.ケ: Project file for THINK C 7.0.4. 68K Only.
Bye.68K.オ: Project file for CodeWarrior 8 that makes 68K application.
Bye.FAT.オ: Project file for CodeWarrior 8 that adds PPC code and makes FAT application.
Source Codes:
Bye.h:
ByeClock common header
Includes constants, type definitions and prototypes.
Bye.main.c:
Includes main event procedures such as mouse and key events.
Bye.menu.c:
Includes menu event procedures.
Bye.dialog.c:
Preferences Dialog and About Dialog procedures
Since Preferences Dialog is modeless, its handling is rather complicated.
Bye.clock.c:
Includes clock maintenance and event watching procedures.
Bye.pref.c:
Includes Preferences File procedures.
Bye.AE.c:
Includes AppleEvent receiving/sending handlers.
Receive handlers are almost dummy.
You will find sending shutdown AppleEvent here.
Bye.rsrc:
Includes resources of ByeClock.
3. Notes when developing
3.1. Partition Size
THINK C user should pay attention to the followings.
I set the partition size (amount of memory consumption of the application) to 64K, which is minimum size for ByeClock to run. However, when you let it run from the THINK Project Manager, it requires more memory than this size. You have to set its size greater when you are developing it.
I checked the partition size under 68K machine. I did not check it enough under PowerPC environment.
3.2. New Toolbox Names
Apple Computer offers new function names for some Toolbox routines.
Example:
GetItem -> GetMenuItemText
GetMHandle -> GetMenuHandle
GetDItem -> GetDialogItem
Secs2Date -> SecondsToDate
Date2Secs -> DateToSeconds
GetDblTime -> GetDoubleClickTime
Apple Computer recommends to use new function names. I follow this manner in the ByeClock source codes. Unfortunately, you cannot search those names using THINK Reference.
3.3 Copland-Savvy Accessors
The latest headers from Apple Computer (currently ETO #18) provide STRICT_WINDOWS definition.
By using this, we can hide WindowRecord or DialogRecord members away. Instead of using WindowPtr or DialogPtr, we can use new type definitions, WindowRef or DialogRef, which hides its members. (They are called Opaque Windows.)
It means, under the STRICT_WINDOWS, we cannot access members of a window directly using WindowRecord (or WindowPeek) structure. DialogRecord (or DialogPeek) neither.
For the substitutions, Apple offers several macros called "accessors" that manipulate WindowRef contents. Apple also announces those accessor will be official APIs under Copland OS.
I think those macros are well-organized and very useful even though I am not curious about Copland. I tried to use them as much as possible in the ByeClock source codes. Though you might be perplexed finding unfamiliar types and functions, you will soon be on intimate terms with them. I strongly recommend you to once read Windows.h, Dialogs.h and QuickDraw.h in the Universal Headers.
For your reference, Both Metrowerks CodeWarrior and Symantec C++ Release 4 include the Universal Headers equivalent to E.T.0. #18.
3.4. Making FAT Application
ByeClock becomes FAT application from the version 0.7. Make 68K application using Bye.68K.オ and add PPC code using Bye.FAT.オ and create FAT application.
4. Terms of Using the Source Code
You can use freely any of source codes in this package. You do not have to need any permissions or credits. You can use them on both commercial and non-commercial aimed products. However, you should follow the next clause: DISCLAIMER terms.
5. DISCLAIMER
The author is not responsible to any casualties using the ByeClock source codes. Use them totally at your own risk.
6. Future Plans
I do not have any particular attachments to ByeClock since it seems to be a commonplace clock utility.
I did not make its icon seriously.
I am surprised, however, that I have received several requests of enhancement, offers of introduction on magazines, requests of including some CDROM discs. I regret I should have designed the icon better one and changed it in version 0.6 but I think it is too late.
I have been accepting request for ByeClock as much as possible but I do not deeply love ByeClock yet.
If any one of you have ideas to grow ByeClock, I will be glad to give you all the ByeClock projects.
7. Bug Info
Version 0.8.1:
The button of the Preferences dialog was incorrectly shown when resume event.
Version 0.8.0:
Preferences creating procedure was incorrect.
Version 0.7.2:
Checks to execute shutdown was insufficient.
Confirm alert appeared when the system is going down and ByeClock is set front process just to quit.
Version 0.7.1:
Not a bug fix release but simplified the header in accordance with Symantec C++ Release 4.
Version 0.7:
Size setting under PPC was still incorrect. Many thanks to Kunihito Koike who indicated this problem.
Version 0.6:
I failed to set heap and stack sizes of ByeClock PPC version. The heap size is my mistake and I could not check the appropriate stack size since I donユt have Power Macintosh.
I greatly thank those two guys: Osamu Hoshino and Katsuyoshi Nakagawa who indicated the problem and helped me much by checking how it works.
Version 0.5:
I hard-coded the date and time string locations but it caused inappropriate indications because of the size differerences between two kinds of Times Fonts from Apple and Adobe Type Manager. I changed the method to calculate the string locations and window sizes according to the current font information. I express my thanking to Tetsuya Mizutori, who pointed out this problem.
Version 0.4:
I received a report that, when installing the Inline++TSM 2.0, Preferences modal dialog of ByeClock 0.4 does not work properly. This problem occurs only using CodeWarrior 68K compiler. THINK C makes proper results.
I could not investigate a true reason but I think this is caused with a bug or peculiarity of CodeWarrior.
Since I could not find any simple solutions, I avoid this problem changing the Preferences dialog to a modeless one.
Due to this revising, the source codes become complex but the user may prefer to use a modeless dialog and I accept this result.
I express my thanking to Mitsuru Nakagawa, the bug reporter, and Hideaki Iimori, the author of the Inline++TSM 2.0, who kindly answered to my questions.
Version 0.3:
In Version 0.3, I made a foolish mistake that I misuse ticks and seconds in Bye.h header.
Because of this mistake, retry interval was set to one hour instead of 10 minutes.
ByeClock 0.3 also has a problem that its source codes could not be compiled using THINK C since I missed several header checks.
7. Contact Address
If you have any doubts or questions, please feel free to contact me to the following address.